import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('ground')
export class ground extends Component {
    @property
    speed:number = 4;

    @property
    width:number = 288;

    start() {

    }

    update(deltaTime: number) {
        for (const element of this.node.children) {
            element.setPosition(
                element.position.x - this.speed*deltaTime,
                element.position.y,element.position.z
            )
            //如果背景超出屏幕
            if(element.position.x<-this.width){
                element.setPosition(
                    element.position.x+this.width*2,
                    element.position.y,element.position.z
                )
            }
        }
    }
}


